package com.zsy.petshop_01.controller;

import com.zsy.petshop_01.common.result.ResponseResult;
import com.zsy.petshop_01.model.entity.LoginInfo;
import com.zsy.petshop_01.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "用户管理")
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public ResponseResult<?> login(@RequestBody LoginInfo loginInfo) {
        return userService.Login(loginInfo);
    }

    @ApiOperation("用户注册")
    @PostMapping("/register")
    public ResponseResult<?> register(@RequestBody LoginInfo loginInfo) {
        return userService.Register(loginInfo);
    }

    @ApiOperation("搜索所有用户")
    @GetMapping("/selectAllUser")
    public ResponseResult<?> selectAllUser(){
        return userService.selectAllUser();
    }

    @ApiOperation("删除用户")
    @PostMapping("/delateByName")
    public ResponseResult<?> delateByName(@RequestBody LoginInfo loginInfo) {
        return userService.delateByName(loginInfo);
    }

    @ApiOperation("设置用户VIP")
    @PostMapping("/setVIP")
    public ResponseResult<?> setVIP(@RequestBody LoginInfo loginInfo) {
        return userService.setVIP(loginInfo);
    }

    @ApiOperation("验证VIP")
    @GetMapping("/verifyVIP")
    public ResponseResult<?> verifyVIP(HttpServletRequest request) {
        return userService.verifyVIP(request);
    }

    @ApiOperation("验证店长")
    @GetMapping("/verifyOwner")
    public ResponseResult<?> verifyOwner(HttpServletRequest request){
        return userService.verifyOwner(request);
    }
}
